
function validateEmpty(fld) {
    var error = "";
    alert("fffff");
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow';
        error = "The required field has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}
function validateFormOnSubmit(theForm) {
    var reason = "";

    reason += validateEmpty(theForm.login);
    //reason += validatePassword(theForm.pwd);
    //reason += validateEmail(theForm.email);
    //reason += validatePhone(theForm.phone);
    //reason += validateEmpty(theForm.from);

    if (reason != "") {
        alert("Some fields need correction:\n" + reason);
        return false;
    }

    return true;
}

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter a username.\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.background = 'Yellow';
        error = "The username is the wrong length.\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = 'Yellow';
        error = "The username contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

